<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<style>
    /*重新设置样式*/
    .form-control {
        width: 196px !important;
        height: 34px !important;
        padding: 10px !important;
    }

</style>
<body class="hold-transition skin-blue sidebar-mini">
<section class="content-header">
    <h1>机械备件库消耗品在库金额</h1>

</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm">
                        <h2 id="title"></h2>
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>项目编号</label>
                                    <input style="width: 123px" type="text" name="ityProCode"
                                           class="form-control"
                                           placeholder="请输入项目编号">
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>项目名称</label>
                                    <input style="width: 123px" type="text" name="ityProName" class="form-control"
                                           placeholder="请输入项目名称">
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>SAP物料编码</label>
                                    <input style="width: 210px" type="text" name="itySapCode" class="form-control"
                                           placeholder="请输入SAP物料编码">
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>物料描述</label>
                                    <input style="width: 210px" type="text" name="ityMatDesc" class="form-control"
                                           placeholder="请输入物料描述">
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>跟踪号</label>
                                    <input style="width: 108px" type="text" name="ityTrackCode" class="form-control"
                                           placeholder="请输入跟踪号">
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>区位</label>
                                    <input style="width: 108px" type="text" name="ityPosition" class="form-control"
                                           placeholder="请输入区位">
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>备注</label>
                                    <input style="width: 108px" type="text" name="ityRemark" class="form-control"
                                           placeholder="请输入备注">
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>在库类型</label>
                                    <select name="ityStockType" class="form-control"
                                            style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width:80px!important;">
                                        <option value="" selected="selected">全部</option>
                                        <option value="1">库存在库</option>
                                        <option value="2">项目在库</option>
                                    </select>
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>仓库</label>
                                    <select id="ityWhiId" name="ityWhiId" class="selectpicker" multiple
                                            data-actions-box="true"
                                            style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width: auto!important;">
                                        <option th:if="${title} == null" selected="selected"
                                                th:each="warehouseInfo:${warehouseInfoList}"
                                                th:value="${warehouseInfo.whiId}"
                                                th:text="${warehouseInfo.whiName}"></option>
                                    </select>
                                    <input type="hidden" style="display: none" name="ityWhiIds"/>
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>生产状态</label>
<!--                                    <select name="proStatus"-->
<!--                                            class="selectpicker"-->
<!--                                            multiple-->
<!--                                            data-actions-box="true"-->
<!--                                            style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width:auto!important;">-->
<!--                                        <option selected="selected" value="1">待制作</option>-->
<!--                                        <option selected="selected" value="2">制作中</option>-->
<!--                                        <option selected="selected" value="3">暂缓</option>-->
<!--                                        <option selected="selected" value="4">完成</option>-->
<!--                                        <option selected="selected" value="5">无状态</option>-->
<!--                                    </select>-->
<!--                                    <input type="hidden" style="display: none" name="proStatusText"/>-->
                                    <select name="proStatus" class="form-control"
                                            style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width:auto!important;">
                                        <option value="" selected="selected">全部</option>
                                        <option value="-1">无状态</option>
                                        <option value="1">未开始</option>
                                        <option value="2">执行中</option>
                                        <option value="3">已完成</option>
                                        <option value="4">取消</option>
                                        <option value="5">暂缓</option>
                                    </select>
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label>记账日期</label>
                                    <input name="startDate" type="text"
                                           class="form-control datepicker" style="width: 100px!important;"
                                           readonly="readonly"> -
                                    <input name="endDate" type="text"
                                           class="form-control datepicker" style="width: 100px!important;"
                                           readonly="readonly">
                                </div>
                                <button type="button" class="btn btn-success" id="btn-search">
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table" style="table-layout: fixed;"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    let table;

    /**
     * 有权看钱没权看星
     * */
    function displayMoney(value) {
        if (hasP('overview:staproduction:view')) {
            if (value == undefined || value == null) {
                return "--";
            }
            return value;
        } else {
            return '***';
        }
    }
    /**
     * 加载库存金额
     */
    function loadTotalPrice(){
        js.post({
            url: ctx + "overview/statistical/amountOfConsumablesInMechanicalSparePartsWarehouse/getTotalPrice",
            data: $("#queryForm").serialize(),
            success: function (result) {
                if (result.type === web_status.SUCCESS) {
                    $('#title').text("机械备件库消耗品在库金额：" + result.data.totalPrice + "元，"+"辽阳：" + result.data.liaoYangTotalPrice + "元，"+"营口：" + result.data.yingKouTotalPrice + "元")
                }
            }
        })
    }
    $(function () {
        /**
         * 仓库多选
         */
        $("#ityWhiId").change(function (){
            $("#queryForm [name='ityWhiIds']").val($("#ityWhiId").val());
        });
        /**
         * 生产状态多选
         */
        $("#queryForm [name='proStatus']").change(function (){
            $("#queryForm [name='proStatusText']").val($("#queryForm [name='proStatus']").val());
        });
        /**
         * 搜索
         */
        $("#btn-search").on('click',function (){
            js.table.search(table);
            loadTotalPrice();
        });
        /**
         * 加载列表
         */
        table = js.table.init({
            url: ctx + "overview/statistical/amountOfConsumablesInMechanicalSparePartsWarehouse/list",
            pageSize: 300,
            showColumns: true,
            showExport: false,
            onLoadSuccess: function (data) {
                loadTotalPrice();
            },
            columns: [
                {
                    title: '序号', field: 'ityId', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {
                    title: '物料描述',
                    field: 'ityMatDesc',
                    width: '120',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return '<p  style="word-wrap: break-word;width: 110px">' + value + '</p>';
                    }
                },
                {
                    title: 'SAP<br>物料编码',
                    field: 'itySapCode',
                    width: '85',
                    sortable: true
                },
                {
                    title: '数量',
                    field: 'ityNum',
                    width: '50',
                    formatter: function (value, row, index) {
                        if (value == undefined || value == null) {
                            value = "--";
                        }
                        return '<p  style="word-wrap: break-word;width: 40px">' + value + '</p>';
                    }
                },
                {
                    title: '单位',
                    field: 'ityNumUnit',
                    width: '50',
                    sortable: true
                },//数量单位
                {
                    title: '单价<br>（元）',
                    field: 'ityPrice',
                    width: '100',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return displayMoney(value);
                    }
                },
                {
                    title: '金额<br>（元）',
                    field: 'ityAmount',
                    width: '100',
                    sortable: true, formatter: function (value, row, index) {
                        return displayMoney(value);
                    }
                },
                {
                    title: '项目编号',
                    field: 'ityProCode',
                    width: '82',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (value == undefined || value == null) {
                            value = "--";
                        }
                        return value;
                    }
                },
                {
                    title: '项目名称',
                    field: 'ityProName',
                    width: '200',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (value == undefined || value == null) {
                            value = "--";
                        }
                        return '<p  style="word-wrap: break-word;width: 190px">' + value + '</p>';
                    }
                },
                {
                    title: '生产状态',
                    field: 'proStatusText',
                    width: '75',
                    sortable: true
                },
                {
                    title: '跟踪号',
                    field: 'ityTrackCode',
                    width: '95',
                    sortable: true
                },
                {
                    title: '在库类型',
                    field: 'stockType',
                    width: '75',
                    sortable: true
                },
                {
                    title: '备注',
                    field: 'ityRemark',
                    sortable: true
                },
                {
                    title: '仓库',
                    field: 'whiName',
                    sortable: true
                },
                {
                    title: '区位',
                    field: 'ityPosition',
                    sortable: true
                },
                {
                    title: '记账日期',
                    field: 'ityBookkeepingDate',
                    width: '100',
                    sortable: true
                }
            ]
        });
    })
</script>
</body>
</html>